import { createRouter, createWebHistory } from "vue-router";

// 定义路由规则
import Home from "@/views/Home/index.vue";
const routes = [
  {
    path: "/",
    component: Home,
    redirect: "/title/1",
    children: [
      {
        path: "/title/:id",
        name: "title",
        component: () => import("@/views/Title/title.vue"),
      },
    ],
  },
  {
    path: "/detail",
    name: "detail",
    redirect: "/detail/title/1",
    component: () => import("@/views/Detail/index.vue"),
    children: [
      {
        path: "/detail/title/:id",
        name: "Preview",
        component: () => import("@/views/Preview/index.vue"),
      },
    ],
  },
];

// 创建路由实例
const router = createRouter({
  history: createWebHistory(), // 使用 HTML5 History 模式 (无 #)
  routes, // 相当于 routes: routes
});

export default router;
